package org.sea.mybator.service;

import org.apache.velocity.VelocityContext;
import org.sea.mybator.util.Constants;
import org.sea.mybator.util.Util;

 

public class CreateJavaDao  extends Create{
    public boolean parse( String tableNameFull) {
        
        VelocityContext context = new VelocityContext();
        String tableName = tableNameFull.replaceAll("T_", "");
        String daoName = Util.getDaoName(tableName);
        String className = Util.getDOName(tableName);
        
        context.put("package",Constants.repositoryPackagePath );
        context.put("daoPath", Constants.repositoryPackagePath + "." + daoName);
        context.put("entityPath",Constants.modelPackagePath + "." + className + "Entity");
        context.put("className", className);
        context.put("edtclassName", className + "Mapper");
        context.put("entityName", className + "Entity");
        context.put("poName", className + "Entity");
        context.put("tprimaryKeyCol", Constants.tprimaryKeyCol);
        context.put("entitySmallName", Util.firstLetterToLowerCase(className));
        context.put("DaoName", daoName);
        context.put("daoName", Util.firstLetterToLowerCase(daoName));

        String filePath =  Constants.createFilePath + className + "Mapper.java"; 
        Util.writeFile("dao_java.vm", context, filePath);
        return false;
    }

    public static void main(String[] args) {
        CreateJavaDao createJavaDao=new CreateJavaDao();
        createJavaDao.parse("T_ATTACH_UPLOAD");
        
    }
}
